[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In the AmigaOS release 2.04, a new handler for passing data between programs was introduced. This handler is called ‘L:Queue-Handler’, better known as the ‘PIPE:’ device.
‘PIPE:’ implements a true pipe
familiar from UNIX systems.
Its function is to pass the output of one program to another program as
input. You can chain several programs together using multiple pipes.
The advantages of using pipes are:
The ‘PIPE:’ device differs from the UNIX pipes in two important respects:
The PIPE: handler name syntax is ‘PIPE:name/bufsize/bufnum’, where
‘name’ is the name for the pipe channel. Using names you can have
several simultaneous pipe operations. The optional arguments
bufsize
and bufnum
specify the size and number of the
buffers used by ‘PIPE:’. Normally, you would just use
‘PIPE:name’.
The default buffer size of ‘PIPE:’ is 4096 bytes, and the number of buffers (ie. channels) is unlimited.
1.1 Using PIPE: in a standard AmigaShell environment | ||
1.2 The Pipe command | ||
1.3 Pipe command support in AmigaShell | ||
1.4 Quick usage guide | ||
1.5 Related things | ||
1.6 Troubleshooting |
Osma Ahvenlampi (Osma.Ahvenlampi@hut.fi)
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
First, make sure ‘PIPE:’ is mounted. You can do this by giving the command
1> Mount PIPE:
in a Shell window. On an AmigaOS 2.1+ system, ‘PIPE:’ is normally mounted on startup by placing the mount entry file ‘PIPE’ in the drawer ‘DEVS:DosDrivers’.
In an AmigaShell window, give the commands:
1> Run List SYS: >PIPE:Listoutput 1> More <PIPE:Listoutput
These two commands list the contents of the ‘SYS:’ volume to a pipe and then type it in the Shell window. You could also use:
1> Run List SYS: NOHEAD >PIPE:Listoutput 1> Run Sort PIPE:Listoutput PIPE:Sortedoutput 1> More <PIPE:Sortedoutput
Notice that you need to ‘Run’ all the programs except for the last one. This is so that you can get them all running simultaneously. You could also use several Shell windows, or any other way of running all the programs at the same time. Also this might not work if ‘More’ isn’t the standard Commodore AmigaOS 2.04+ More found in ‘SYS:Utilities’.
In case you need to manually flush a pipe, for example because the program that was reading from it aborts prematurely, it can be done with the command:
1> Type PIPE:name TO NIL:
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
As you can see, this is a somewhat difficult way of using pipes, needing a lot of typing especially compared to the UNIX pipes. There is a solution for that.
Andy Finkel, a former Commodore software engineer wrote a command
called Pipe
(not to be confused with ‘PIPE:’) that
simplifies the use of the ‘PIPE:’ device. Unfortunately, this
command did not make it into the 2.04 release. However, Commodore
has given the permission to distribute this, and a few other
commands, freely. (Sources: Fish disk 673, Aminet,
‘util/cli/finkelshelltools.lha’)
For some reason Commodore did not include these commands in the later OS releases, although they work fine even with OS 3.1 (V40). Thus all users are required to get them from the above sources if they wish to use them.
The Pipe command usage is simple. The commands to be run with their inputs and outputs piped together are given as arguments to the command, separated by the <|> (vertical bar) character:
1> Pipe List SYS: | More or 1> Pipe List: SYS: NOHEAD | Sort IN: OUT: | More
Notice how Sort needs ‘IN:’ and ‘OUT:’. These devices don’t actually exist, but the Pipe command simulates them with the PIPE:. This is necessary because C:Sort can not use the ‘standard IO’, but insists on files.
The separator character <|> can be configured to be something else with the local variable __pchar.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There is a little known and quite useful undocumented feature built in
the 2.04+ AmigaShell, that is, AmigaShell knows about the Pipe
command. By setting the local variable _pchar, you can use pipes
without even entering the Pipe command. AmigaShell will prepend it on
the command line automatically if it sees the pipe separator command
specified by _pchar on the command line.
Thus, after the command:
1> Set _pchar "|"
the above examples can be used like this:
1> List SYS: | More or 1> List SYS: NOHEAD | Sort IN: OUT: | More
Those familiar with the UNIX pipes will notice how the usage is very similar to the UNIX pipe usage.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The variable _mchar is used to separate one command from another in a shell line. So, after the command:
1> Set _mchar ";"
you can put more shell commands into the same line,
separated from each other by ;
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When I try the command ‘List SYS: | More’ I get an error
PIPE: Unknown command
I have ‘PIPE:’ mounted, what’s wrong?
AmigaShell is referring to the command Pipe
in the error, not the
‘PIPE:’ device. You haven’t installed the commands in the ShellTools
archive.
I get a requester that says
Please insert volume PIPE: in any drive
when I try any of the command examples.
‘PIPE:’ is not mounted. Try ‘Mount PIPE:’. If that doesn’t work, refer to your AmigaDOS manual or a friend that knows how to mount devices.
When I try any of the examples the More window pops up but nothing is shown/I get an error afterwards/More pops up a file requester.
You are not using the standard AmigaOS More
command. Either use
another name or install a command that supports pipes.
Possibilities are the C= More, Less, or Most for example.
With use of PIPE:, sometimes characters get lost. What happened?
Up to OS 3.1, the queue-handler has some bugs which don’t allow a really foolproof transmission of data. A compatible replacement for the queue-handler can be founbd on Aminet, ‘util/sys/HWGQueue.lha’.
None of these happen but it still doesn’t work as you described.
Are you using OS 2.04 later? Are you using the standard AmigaShell? Try with all extras disabled.
[Top] | [Contents] | [Index] | [ ? ] |
Note that ‘1>’ is the prompt AmigaShell gives when it is waiting for a command. The number varies, and the prompt can be customised to look completely different. It is not a part of the command.
The quotes around the vertical bar are important, to avoid AmigaShell interpreting the command as an attempt to use PIPE:, if _pchar is already set (for example if the Shell is started from within another one).
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated on February 12, 2023 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ Up ] | Up | Up section | 1.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated on February 12, 2023 using texi2html 5.0.